package com.ailiwu.www.ailiwu.activity;

import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.support.v7.app.AppCompatActivity;
import android.view.Window;
import android.view.WindowManager;

import com.ailiwu.www.ailiwu.R;
import com.ailiwu.www.ailiwu.utils.SharedPrefUtils;

/**
 * Author:    Yyang
 * Version    V1.0
 * Date:      2015.12.2  16:08.
 * Description: Splash界面
 * Modification  History:
 * Date         	Author        		Version        	Description
 * -----------------------------------------------------------------------------------
 * 2015.12.2        Yyang                1.0                1.0
 * Why & What is modified:
 */
public class SplashActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        this.requestWindowFeature(Window.FEATURE_NO_TITLE);
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_splash);

        this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);

        final Handler h = new Handler();
        h.postDelayed(new Runnable() {
            @Override
            public void run() {
                // 判断是否是第一次开启软件
                if (SharedPrefUtils.getBoolean(SplashActivity.this, "isFirst", true)) {

                    //开启NavigationActivity界面
                    Intent intent = new Intent(SplashActivity.this, NavigationActivity.class);
                    startActivity(intent);
                    // 设置isFirst值为false;
                    SharedPrefUtils.saveBoolean(SplashActivity.this, "isFirst", false);
                    finish();

                } else {
                    //开启主界面
                    Intent intent = new Intent(SplashActivity.this, MainActivity.class);
                    startActivity(intent);
                    finish();
                }
            }
        }, 2000);


    }

}
